package com.adv.ems.controller.client;

import com.adv.ems.constants.SystemConst;
import com.adv.ems.model.dto.APIRequest;
import com.adv.ems.model.dto.APIResponse;
import com.adv.ems.model.param.EnergySearchOnlineValueParam;
import com.adv.ems.model.param.EnergySearchSubjectTreeParam;
import com.adv.ems.model.vo.EnergySearchCircuitDiagramTreeVO;
import com.adv.ems.model.vo.EnergySearchOnlineValueVO;
import com.adv.ems.model.vo.EnergySearchSubjectTreeVO;
import com.adv.ems.service.EnergySearchService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

@RestController
@RequestMapping("/ems/client/energy/search")
public class EnergySearchController {
    @Resource
    EnergySearchService energySearchService;
    @PostMapping("/subject/tree")
    public APIResponse<EnergySearchSubjectTreeVO> subjectTree(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage,
                                                              @RequestBody APIRequest<EnergySearchSubjectTreeParam> request) {
        return APIResponse.<EnergySearchSubjectTreeVO>build().content(energySearchService.subjectTree(request.getContent(), acceptLanguage));
    }

    @PostMapping("/circuit/diagram/tree")
    public APIResponse<EnergySearchCircuitDiagramTreeVO> diagramTree(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage,
                                                                     @RequestBody APIRequest<EnergySearchSubjectTreeParam> request) {
        return APIResponse.<EnergySearchCircuitDiagramTreeVO>build().content(energySearchService.diagramTree(request.getContent(), acceptLanguage));
    }

    @PostMapping("/online/value")
    public APIResponse<EnergySearchOnlineValueVO> onlineValue(@RequestHeader(name = SystemConst.Header.ACCEPT_LANGUAGE, defaultValue = SystemConst.Header.ZH_CN) String acceptLanguage,
                                                              @RequestBody APIRequest<EnergySearchOnlineValueParam> request) {
        return APIResponse.<EnergySearchOnlineValueVO>build().content(energySearchService.onlineValue(request.getContent(), acceptLanguage));
    }

}
